home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / game / shoot / ADoom_src_1_2.lha / ADoom_src / amiga_mmu.s < prev    next >
Text File  |  1998-03-01  |  3KB  |  164 lines

  1.         mc68040
  2.  
  3.         section    text,code
  4.  
  5. *
  6. *   mmu.s - 68040/68060 MMU control functions
  7. *   Copyright (C) 1997 Aki Laukkanen
  8. *
  9.  
  10.         XDEF    _mmu_mark
  11.  
  12.         include "exec/types.i"
  13.         include "exec/memory.i"
  14.         include "exec/funcdef.i"
  15.         include "exec/exec_lib.i"
  16.         include "amiga_mmu.i"
  17.  
  18.     IFND    TRUE
  19. TRUE EQU    1
  20.     ENDC
  21.  
  22.     IFND    FALSE
  23. FALSE EQU   0
  24.     ENDC
  25.  
  26. *
  27. *   FUNCTION
  28. *       UBYTE __asm mmu_mark (register __a0 UBYTE *start,
  29. *                             register __d0 ULONG length,
  30. *                             register __d1 ULONG cm,
  31. *                             register __a6 struct ExecBase *SysBase);
  32. *
  33. *   SYNOPSIS
  34. *       Changes the cache mode for the specified memory area. This
  35. *       area  must be aligned by 4kB and be multiple of 4kB in size.
  36. *
  37. *   RESULT
  38. *       Returns the old cache mode for the memory area.
  39. *
  40. *   NOTES
  41. *       Works only after setpatch has been issued and in such
  42. *       systems where 68040.library/68060.library is correctly
  43. *       installed.
  44. *
  45.  
  46. _mmu_mark
  47.         movem.l    d2/d3/d7/a2/a4/a6,-(sp)
  48.  
  49.         move.l    a1,a4
  50.         movem.l    d0/d1/a0,-(sp)
  51.         jsr    (_LVOSuperState,a6)
  52.         movec    tc,d3            ; translation code register
  53.         movec    urp,d2            ; user root pointer
  54.         jsr    (_LVOUserState,a6)
  55.         movem.l    (sp)+,d0/d1/a0
  56.  
  57.         btst    #TCB_E,d3
  58.         beq    .error
  59.         btst    #TCB_P,d3
  60.         bne    .error
  61.  
  62.         move.l    d1,-(sp)
  63.         move.l    d0,d1
  64.  
  65.         lsr.l    #8,d0
  66.         lsr.l    #4,d0
  67.  
  68.         move.l    a0,a1
  69.  
  70.         and.w    #$fff,d1
  71.         beq.s    .skip_a
  72.         addq.l    #1,d0
  73. .skip_a
  74.         move.l    (sp)+,d1
  75.         subq.l    #1,d0
  76.         move.l    d0,d7
  77.  
  78. ; a1 - chunkybuffer
  79. ; d7 - counter
  80. ; d2 - urp
  81. ; d1 - cache mode
  82.  
  83. .loop
  84.         move.l    d2,-(sp)
  85.         move.l    a1,d0
  86.         rol.l    #8,d0
  87.         lsl.l    #1,d0
  88.         and.w    #%1111111000000000,d2
  89.         and.w    #%0000000111111100,d0
  90.         or.w    d0,d2
  91.         move.l    d2,a2
  92.         move.l    (a2),d2
  93.         btst    #TDB_UDT0,d2
  94.         beq    .skip            ; if 0
  95.         btst    #TDB_UDT1,d2        ; if 1
  96.         beq    .end
  97.         bra    .skip2
  98. .skip
  99.         btst    #TDB_UDT1,d2
  100.         bne    .end
  101. .skip2
  102.         move.l    a1,d0
  103.         lsr.l    #8,d0
  104.         lsr.l    #8,d0
  105.         and.w    #%1111111000000000,d2
  106.         and.w    #%0000000111111100,d0
  107.         or.w    d0,d2
  108.         move.l    d2,a2
  109.         move.l    (a2),d2
  110.         btst    #TDB_UDT0,d2
  111.         beq    .skip1            ; if 0
  112.         btst    #TDB_UDT1,d2        ; if 1
  113.         beq    .end
  114.         bra    .skip3
  115. .skip1
  116.         btst    #TDB_UDT1,d2
  117.         bne    .end
  118. .skip3
  119.         move.l    a1,d0
  120.         lsr.l    #8,d0
  121.         lsr.l    #2,d0
  122.         and.w    #%1111111100000000,d2
  123.         and.w    #%0000000011111100,d0
  124.         or.w    d0,d2
  125.  
  126.         move.l    d2,a2
  127.         btst    #PDB_PDT1,(3,a2)
  128.         bne    .skip4
  129.         btst    #PDB_PDT0,(3,a2)
  130.         beq    .end
  131.         bra    .skip5
  132. .skip4
  133.         btst    #PDB_PDT0,(3,a2)
  134.         beq    .indirect
  135. .skip5
  136.         move.b    (3,a2),d3
  137.         and.b    #~CM_MASK,(3,a2)
  138.         or.b    d1,(3,a2)
  139.  
  140. .indirect
  141.         lea    (4096,a1),a1
  142.  
  143.         move.l    (sp)+,d2
  144.         dbf    d7,.loop
  145.  
  146.         and.b    #CM_MASK,d3
  147.         jsr    (_LVOSuperState,a6)
  148.         pflusha
  149.         jsr    (_LVOUserState,a6)
  150.  
  151.         moveq    #0,d0
  152.         move.b    d3,d0
  153.  
  154.         movem.l    (sp)+,d2/d3/d7/a2/a4/a6
  155.         rts
  156. .end
  157.         move.l    (sp)+,d2
  158. .error
  159.         movem.l    (sp)+,d2/d3/d7/a2/a4/a6
  160.         moveq    #0,d0
  161.         rts
  162.  
  163.         end
  164.